/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.news;

import android.app.Activity;
import  android.content.res.Resources;
public class Directory {
    private static DirectoryCategory[] categories;
    
    public static void initializeDirectory(Activity activity) {
        Resources rs = activity.getResources();
        
        String mSrcZeroA = rs.getString(R.string.src_zero_a_url);
        String mSrcZeroB = rs.getString(R.string.src_zero_b_url);
        String mSrcZeroC = rs.getString(R.string.src_zero_c_url);
        
        String mSrcOneA = rs.getString(R.string.src_one_a_url);
        String mSrcOneB = rs.getString(R.string.src_one_b_url);
        String mSrcOneC = rs.getString(R.string.src_one_c_url);
        
    
        DirectoryCategory categoryZero = new DirectoryCategory(rs.getString(R.string.src_zero), new DirectoryEntry[] {
            new DirectoryEntry(rs.getString(R.string.src_zero_a)),
            new DirectoryEntry(rs.getString(R.string.src_zero_b)),
            new DirectoryEntry(rs.getString(R.string.src_zero_c))
            });
        categoryZero.getEntry(0).setUrl(mSrcZeroA);
        categoryZero.getEntry(1).setUrl(mSrcZeroB);
        categoryZero.getEntry(2).setUrl(mSrcZeroC);
        
        DirectoryCategory categoryOne = new DirectoryCategory(rs.getString(R.string.src_one), new DirectoryEntry[] {
            new DirectoryEntry(rs.getString(R.string.src_one_a)),
            new DirectoryEntry(rs.getString(R.string.src_one_b)),
            new DirectoryEntry(rs.getString(R.string.src_one_c))});
        categoryOne.getEntry(0).setUrl(mSrcOneA);
        categoryOne.getEntry(1).setUrl(mSrcOneB);
        categoryOne.getEntry(2).setUrl(mSrcOneC);
        
        categories = new DirectoryCategory[] { categoryZero,
                                               categoryOne
                };
    }

    public static int getCategoryCount() {
        return categories.length;
    }

    public static DirectoryCategory getCategory(int i) {
        return categories[i];
    }
}
